/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelos_programa;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
 * Write a description of class Conexion here.
 * 
 * @author Rey Salcedo 
 * @version (a version number or a date)
 */
public class Conexion{
	Connection conexion;
	Statement consulta;
        String db, user, password, r;

    /**
     * Constructor for objects of class Conexion
     */
    public Conexion()
    {
        File miDir = new File (".");
            try {
                r=miDir.getCanonicalPath();
            } catch (IOException ex) {
                Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
            }
        db= r+"\\SIMULACION.FDB";
        user = "sysdba";
        password = "masterkey";
    }
    public Connection conectar(){
		try {
	            Class.forName("org.firebirdsql.jdbc.FBDriver");
	        }
	        catch (ClassNotFoundException e) {
	            JOptionPane.showMessageDialog(null, e.getMessage());
	        }	 
			try {
                            conexion = DriverManager.getConnection("jdbc:firebirdsql://localhost/" + db,this.user, this.password);
                            consulta = conexion.createStatement();
			} catch (SQLException e) {
                            JOptionPane.showMessageDialog(null, e.getMessage());
                        }
                       return  conexion;
	}
    
}
